package com.example.xui_study;

import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.Toast;

import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class DialogActivity extends BaseActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);

        ButterKnife.bind(this);

    }

    @OnClick({R.id.bt_back,R.id.bt_show_dialog_tip,R.id.bt_show_dialog_input,R.id.bt_show_dialog_interaction})
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bt_show_dialog_tip:
                new MaterialDialog.Builder(DialogActivity.this)
                        .iconRes(R.mipmap.icon_tip)
                        .title("提示")
                        .content("提示内容")
                        .positiveText("确认")
                        .show();
                break;

            case R.id.bt_show_dialog_input:
                new MaterialDialog.Builder(DialogActivity.this)
                        .iconRes(R.mipmap.icon_warning)
                        .title("警告")
                        .content("当前为开发环境，是否切换到真实环境")
                        .inputType(
                                InputType.TYPE_CLASS_TEXT
                                        | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                                        | InputType.TYPE_TEXT_FLAG_CAP_WORDS)
                        .input(
                                "请输入密码",
                                "",
                                false,
                                ((dialog, input) -> Toast.makeText(DialogActivity.this,input.toString(),Toast.LENGTH_SHORT).show()))
                        .inputRange(6, 20)
                        .positiveText("继续")
                        .negativeText("切换")
                        .onPositive(
                                ((dialog, which) -> Toast.makeText(DialogActivity.this,dialog.getInputEditText().getText().toString(),Toast.LENGTH_SHORT).show())
                        )
                        .cancelable(false)
                        .show();
                break;

            case R.id.bt_show_dialog_interaction:
                new MaterialDialog.Builder(DialogActivity.this)
                        .content("是否允许打开蓝牙")
                        .positiveText("是")
                        .negativeText("否")
                        .onPositive(
                                ((dialog, which) -> Toast.makeText(DialogActivity.this,"你点击了 是",Toast.LENGTH_SHORT).show())
                        )
                        .onNegative(
                                ((dialog, which) -> Toast.makeText(DialogActivity.this,"你点击了 否",Toast.LENGTH_SHORT).show())
                        )
                        .show();
                break;
            case R.id.bt_back:
                onBackPressed();
                break;
        }
    }
}
